<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<!-- 页面meta -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>商品编辑</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
	name="viewport">

<link rel="stylesheet"
	href="seller/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="seller/plugins/adminLTE/css/AdminLTE.css">
<link rel="stylesheet"
	href="seller/plugins/adminLTE/css/skins/_all-skins.min.css">
<link rel="stylesheet" href="seller/css/style.css">

<script src="seller/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="seller/plugins/angularjs/angular.min.js"></script>
<script src="seller/plugins/bootstrap/js/bootstrap.min.js"></script>
<!-- 引入angularjs -->
<script src="angularjs_file/public/argularjs_module.js"></script>
<script src="angularjs_file/service/goodsService.js"></script>
<script src="angularjs_file/public/uploadFile.js"></script>
<script src="angularjs_file/controller/goodsController.js"></script>



<!-- 富文本编辑器 -->
<link rel="stylesheet" href="seller/plugins/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="seller/plugins/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="seller/plugins/kindeditor/lang/zh_CN.js"></script>

</head>

<body class="hold-transition skin-red sidebar-mini" ng-app="shopOnline" ng-controller="goodsController" ng-init="findItemCat1List()">

	<!-- 正文区域 -->
	<section class="content">
	<form id="goodForm" >
		<div class="box-body">

			<!--tab页-->
			<div class="nav-tabs-custom">

				<!--tab头-->
				<ul class="nav nav-tabs">
					<li class="active"><a href="#home" data-toggle="tab">商品基本信息</a>
					</li>
					<li><a href="#pic_upload" data-toggle="tab">商品图片</a></li>
					<li><a href="#customAttribute" data-toggle="tab">扩展属性</a></li>
					<li><a href="#spec" data-toggle="tab">规格</a></li>
				</ul>
				<!--tab头/-->

				<!--tab内容-->
				<div class="tab-content">

					<!--表单内容-->
					<div class="tab-pane active" id="home">
						<div class="row data-type">
							<div class="col-md-2 title">商品分类</div>

							<div class="col-md-10 data">
								<table>
									<tr>
										<td><select class="form-control" ng-model="entity.customGoods.category1Id" ng-options="itemCat.id as itemCat.name for itemCat in itemCat1List"></select></td>
										<td><select class="form-control select-sm" ng-model="entity.customGoods.category2Id" ng-options="itemCat.id as itemCat.name for itemCat in itemCat2List"></select></td>
										<td><select class="form-control select-sm" ng-model="entity.customGoods.category3Id" ng-options="itemCat.id as itemCat.name for itemCat in itemCat3List"></select></td>
										<td>模板ID:{{entity.customGoods.typeTemplateId}}</td>
										 
									</tr>
								</table>
                               <input type="hidden" id="typeTemplate_id_hidden"  value="">
							</div>


							<div class="col-md-2 title">商品名称</div>
							<div class="col-md-10 data">
								<input type="text" class="form-control" ng-model="entity.customGoods.goodsName"
									 placeholder="商品名称" value="">
							</div>

							<div class="col-md-2 title">品牌</div>
							<div class="col-md-10 data">
								<select class="form-control" ng-model="entity.customGoods.brandId" ng-options="itemCat.id as itemCat.text for itemCat in tempBrandIds">
									
							</div>

							<div class="col-md-2 title">副标题</div>
							<div class="col-md-10 data">
								<input type="text" class="form-control" ng-model="entity.customGoods.caption"
									placeholder="副标题" value="">
							</div>

							<div class="col-md-2 title">价格</div>
							<div class="col-md-10 data">
								<div class="input-group">
									<span class="input-group-addon">¥</span> <input type="text"
										class="form-control" ng-model="entity.customGoods.price" placeholder="价格"
										value="">
								</div>
							</div>

							<div class="col-md-2 title editer">商品介绍</div>
							<div class="col-md-10 data editer">
								<textarea name="customGoodsdesc.introduction" style="width:800px;height:400px;visibility:hidden;" ></textarea>
							</div>

							<div class="col-md-2 title rowHeight2x">包装列表</div>
							<div class="col-md-10 data rowHeight2x">

								<textarea rows="4" class="form-control" ng-model="entity.customGoodsdesc.packageList"
									 placeholder="包装列表"></textarea>
							</div>

							<div class="col-md-2 title rowHeight2x">售后服务</div>
							<div class="col-md-10 data rowHeight2x">
								<textarea rows="4" class="form-control" ng-model="entity.customGoodsdesc.saleService"
								 placeholder="售后服务"></textarea>
							</div>


						</div>
					</div>

					<!--图片上传-->
					 <div class="tab-pane" id="pic_upload">
						<div class="row data-type">
							颜色图片
							<div class="btn-group">
								<button type="button" class="btn btn-default" title="新建"
									data-target="#uploadModal" data-toggle="modal" ng-click="image_entity={}">
									<i class="fa fa-file-o"></i> 新建
								</button>

							</div>

							<table
								class="table table-bordered table-striped table-hover dataTable">
								<thead>
									<tr>

										<th class="sorting">颜色</th>
										<th class="sorting">图片</th>
										<th class="sorting">操作</th>
								</thead>
								<tbody>
									<tr ng-repeat="pojo in entity.customGoodsdesc.itemImages">
										<td>{{pojo.color}}</td>
										<td><img alt="图片加载失败" id="pic_inlist" src="{{pojo.url}}" width="100px" height="100px">
										</td>
										<td>
											<button type="button" class="btn btn-default" ng-click="remove_image_entity($index)" title="删除">
												<i class="fa fa-trash-o"></i> 删除
											</button>
										</td>
									</tr>
								</tbody>
							</table>

						</div>
					</div> 


					<!--扩展属性-->
					<div class="tab-pane" id="customAttribute">
						<div class="row data-type">
							<div ng-repeat="temp in entity.customGoodsdesc.customAttributeItems">
								<div class="col-md-2 title">{{temp.text}}</div>
								<div class="col-md-10 data">
									<input class="form-control" placeholder="{{temp.text}}" ng-model="temp.value">
								</div>
							</div>
							
						</div>
					</div>

					<!--规格-->
					<div class="tab-pane" id="spec">
						<div class="row data-type">
							<div class="col-md-2 title">是否启用规格</div>
							<div class="col-md-10 data">
								<input type="checkbox" ng-model="entity.customGoods.isEnableSpec" ng-true-value="1" ng-false-value="0">
							</div>
						</div>
						<p>
						<div ng-if="entity.customGoods.isEnableSpec==1">

							<div class="row data-type">

								<div ng-repeat="pojo in speclsit">
									<div class="col-md-2 title">{{pojo.text}}</div>
									<div class="col-md-10 data">

										<span ng-repeat="options in pojo.options"> 
										<input type="checkbox" ng-click="updateSpecAttribute($event,pojo.text,options.optionName);createItemLsit()">{{options.optionName}}
										</span> 

									</div>
								</div>
						

							</>

							<div class="row data-type">
								<table
									class="table table-bordered table-striped table-hover dataTable">
									<thead>
										<tr>
											<th class="sorting" ng-repeat="title in entity.customGoodsdesc.specificationItems">{{title.attributeName}}</th>
											
											<th class="sorting">价格</th>
											<th class="sorting">库存</th>
											<th class="sorting">是否启用</th>
											<th class="sorting">是否默认</th>
										</tr>
									</thead>
									<tbody>
										<tr ng-repeat="pojo in entity.itemLst">
											<td ng-repeat="option in entity.customGoodsdesc.specificationItems">
											{{pojo.spec[option.attributeName]}}
											</td>
											
											<td><input class="form-control" placeholder="价格" ng-model="pojo.price">
											</td>
											<td><input class="form-control" placeholder="库存数量" ng-model="pojo.num">
											</td>
											<td><input type="checkbox" ng-model="pojo.status" ng-true-value="1" ng-false-value="0"></td>
											<td><input type="checkbox" ng-model="pojo.isDefault" ng-true-value="1" ng-false-value="0"></td>
										</tr>
										

									</tbody>
								</table>

							</div>

						</div>
					</div>

				</div>
				<!--tab内容/-->
				<!--表单内容/-->

			</div>




		</div>
		<div class="btn-toolbar list-toolbar">
			<button class="btn btn-primary" ng-click="save()">
				<i class="fa fa-save"></i>保存
			</button>
			<button class="btn btn-default" id="backList">返回列表</button>
		</div>
	</form>
	</section>


	<!-- 上传窗口 -->
 	<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
	
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">×</button>
					<h3 id="myModalLabel">上传商品图片</h3>
				</div>
				<div class="modal-body">

					<table class="table table-bordered table-striped">
						<tr>
							<td>描述</td>
							<td><input class="form-control" placeholder="颜色" ng-model="image_entity.color"></td>
						</tr>
						<tr>
							<td>商品图片</td>
							<td>
							
								<table>
									<tr>
										<td><input type="file" id="file" name="file"/>
											<button class="btn btn-primary" type="button" id="picUpload" ng-click="uploadFile()">上传</button></td>
										<td><img id="img_id" src="{{image_entity.url}}" width="200px" height="200px"></td>
									</tr>
								</table>
							
							</td>
						</tr>
					</table>

				</div>
				<div class="modal-footer">
					<button class="btn btn-success" id="save_pic" data-dismiss="modal"
						aria-hidden="true" ng-click="add_image_entity()">保存</button>
					<button class="btn btn-default" data-dismiss="modal"
						aria-hidden="true">关闭</button>
				</div>
			</div>
		</div>
	
	</div> 


	<!-- 正文区域 /-->
	<script type="text/javascript">
	
		var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="customGoodsdesc.introduction"]', {
				allowFileManager : true
			});
	
		});
		//返回列表
		$("#backList").click(function(){
		location.href="goods/goodsShow.action";
		
		});
	</script>

</body>

</html>

